<template>
    <nav id="nav">
        <li v-for="(item,key) in list">
            <router-link :to="item.path " active-class="active" exact tag="a">{{ item.name }} </router-link>
        </li>
        <router-view></router-view>
    </nav>

</template>


<script>
import config from "../config/config.js";
import store from "../store/newStore.js";

export default {
    store,
    data() {
        return {
            list: []
        };
    },
    computed: {
        ticket() {
            return this.$store.state.getTicket;
        }
    },
    methods: {},
    mounted() {
        axios
            .post(
                "/Home/home/HomeTitle",
                {
                    ticket: this.ticket
                },
                config
            )
            .then(
                function(response) {
                    if (response.data.code == 200) {
                        var items = response.data.data;
                        var pathArr = [
                            "/home/index",
                            "/home/fruits",
                            "/home/dresser",
                            "/home/useday",
                            "/home/specialty",
                            "/home/mother",
                            "/home/others"
                        ];
                        for (var i = 0; i < items.length; i++) {
                            (function() {
                                items[i].path =
                                    pathArr[i] + "/" + items[i].catid;
                            })(i);
                        }
                        this.list = items;
                    }
                }.bind(this)
            )
            .catch(function(error) {
                console.log(error);
            });
    }
};
</script>
	
<style>
</style>